home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / cup_cupinformation.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  17KB  |  620 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    CUP INFORMATION PROGRAM FOR FOOTBALL REXX SUITE
  5.   -------------------------------------------------
  6.                    Copyright  Mark Naughton 1998
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       140998   First release.
  12.            160998   Changed way best record is calculated.
  13.            250899   Added error msg to file check.
  14.            050999   Converted to use locale. Some error messages, before
  15.                     reading the locale, will still be in English.
  16.            050999   Report shows better words for the settings for the
  17.                     rounds - Have decided to keep the datafile settings in
  18.                     English for easier controls - looks better though....
  19.  
  20. **************************************************************************
  21.  
  22. Procedure
  23. ---------
  24.  
  25. 1. Check files exist.
  26. 2. Read '.cf' file and get details. Read '.cfrw' and do the same.
  27. 3. If '.cfsave' doesn't exist, read the '.scf' file adjusting the output
  28.    for replays, extra time, first leg and penalties.
  29. 4. If '.cfsave' is found, read to display current matches.
  30. 5. Read '.scf' into an array. Search array, storing goals. When finished,
  31.    search through the team array, calculating the best record :
  32.  
  33.     (Goals Scored / Goals Away) * Matches Played
  34.  
  35.     Goals Scored = Goals Scored At Home + (Goals Scored Away * 1.5)
  36.  
  37. 6. Write data to a file and call an external sort program. Read the details
  38.    back in and delete the temporary file.
  39. 7. Adjust options.
  40. 8. Display report : display options/rounds, teams and the best record, the
  41.    current round matches and if the history file has been selected, read
  42.    the file for previous/current winners.
  43. 9. Exit.
  44.  
  45. ************************************************************************** */
  46. PARSE ARG league_stuff
  47.  
  48. version      = 1
  49. input_file   = '.cf'
  50. input2_file  = '.scf'
  51. input3_file  = '.cfrw'
  52. input4_file  = '.cfh'
  53. input5_file  = '.cfsave'
  54. output_file  = 'RAM:Football.tempcup'
  55. title        = '*CUP_TITLE='
  56. thirdpl      = '*CUP_THIRD='
  57. rounddef     = '*CUP_RNDDEF='
  58. currond      = '*CUP_ROND='
  59. currrondn    = '*CUP_CRDN='
  60. roundddef    = '*CUP_RDEF='
  61. cuphistory   = '*CUP_HISTORY='
  62. thirdpl      = '*CUP_THIRD='
  63. teams_cnt    = '*CUP_TCNT='
  64. awaygs       = '*CUP_AWAYG='
  65. schedtype    = '*CUP_SCHEDULE='
  66. first        = '*WINNER='
  67. pkversion    = '*  Version='
  68. matches.     = '???'
  69. separator    = '*'
  70. teams.       = '???'
  71. rnds.        = '???'
  72. lines.       = '???'
  73. replays.     = '???'
  74. working.     = '???'
  75. losing.      = '???'
  76. repct        = 0
  77. repno.       = '???'
  78. tcount       = 0
  79. ttc          = 0
  80. rndcnt       = 0
  81. linesct      = 0
  82. /* league_file  = "Data/"league_stuff */
  83. curnd        = ''
  84. curndn       = 0
  85. not_played   = "__   __"
  86. mcount       = 0
  87. bstats.      = '???'
  88. btemp.       = '???'
  89. btcnt        = 0
  90. bpstats.     = '???'
  91. bgsstats.    = '???'
  92. bgastats.    = '???'
  93. bagstats.    = '???'
  94.  
  95.  
  96. parse var league_stuff league_file search_team
  97. league_file = "Data/" || league_file
  98.  
  99. if open(datafile,"Data/Football.locale",'r') then do
  100.    line = readln(datafile)
  101.    locdir = strip(line)
  102.    close(datafile)
  103. end
  104. else do
  105.    say
  106.    say "ERROR :    (CupInformation)"
  107.    say
  108.    say "Cannot read 'Data/Football.locale' for the locale settings."
  109.    exit
  110. end
  111.  
  112. dcupdir = locdir"Football.locale_cup"
  113. locdir  = locdir"User/Cup_CupInformation.data"
  114.  
  115. if open(datafile,"ENV:FootballRXPath",'r') then do
  116.    line = readln(datafile)
  117.    rxdir = strip(line)
  118.    close(datafile)
  119. end
  120. else
  121.    rxdir = "SYS:Rexxc/"
  122.  
  123. if exists(locdir) > 0 then do
  124.   address command rxdir'rx 'locdir
  125.   VarCount = getclip('VarCount')
  126.   do i = 1 to VarCount
  127.     interpret getclip('var.'i)
  128.   end
  129. end
  130. else do
  131.    say
  132.    say "ERROR :    (CupInformation)"
  133.    say
  134.    say "Cannot find '"locdir"' to read locale settings."
  135.    exit
  136. end
  137.  
  138. if exists(dcupdir) > 0 then do
  139.   address command rxdir'rx 'dcupdir
  140.   VarCount = getclip('VarCount')
  141.   do i = 1 to VarCount
  142.     interpret getclip('var.'i)
  143.   end
  144. end
  145. else do
  146.    say
  147.    say "ERROR :    (CupInformation)"
  148.    say
  149.    say "Cannot find '"dcupdir"' to read cup locale settings."
  150.    exit
  151. end
  152.  
  153.  
  154. if exists(league_file || input_file) = 0  then do
  155.    say
  156.    say ci_error
  157.    say
  158.    say ci_t1"'"league_file || input_file"'."
  159.    exit
  160. end
  161.  
  162. if exists(league_file || input2_file) = 0 then do
  163.    say
  164.    say ci_error
  165.    say
  166.    say ci_t1"'"league_file || input2_file"'."
  167.    exit
  168. end
  169.  
  170. tcount = 0
  171. if open(datafile,league_file || input_file,'r') then do
  172.    do while ~eof(datafile)
  173.       line = readln(datafile)
  174.       if pos(title,line) > 0 then        cupname  = delstr(line,1,11)
  175.       if pos(thirdpl,line) > 0 then      third    = delstr(line,1,11)
  176.       if pos(awaygs,line) > 0 then       awaygoals= delstr(line,1,11)
  177.       if pos(pkversion,line) > 0 then    fversion = delstr(line,1,12)
  178.       if pos(cuphistory,line) > 0 then   cuph     = delstr(line,1,13)
  179.       if pos(schedtype,line) > 0 then    scht     = delstr(line,1,14)
  180.       if pos(rounddef,line) > 0 then do
  181.          rndcnt = rndcnt + 1
  182.          rnds.rndcnt = delstr(line,1,12)
  183.       end
  184.       if pos(separator,line) = 0 then do
  185.          line = strip(line)
  186.          tcount       = tcount + 1
  187.          teams.tcount = line
  188.       end
  189.    end
  190.    close(datafile)
  191. end
  192. else do
  193.    say
  194.    say ci_error
  195.    say
  196.    say ci_t2"'"league_file || input_file"'."
  197.    exit
  198. end
  199.  
  200. if open(datafile,league_file || input3_file,'r') then do
  201.    do while ~eof(datafile)
  202.       line = readln(datafile)
  203.       if pos(currond,line)   > 0 then crond  = strip(substr(line,11,2))
  204.       if pos(roundddef,line) > 0 then tcrondn= strip(substr(line,11,5))
  205.       if pos(currrondn,line) > 0 then do
  206.          crondn = strip(substr(line,11,30))
  207.          tleg_no = 0
  208.          if pos("1 Leg",line) > 0 then tleg_no = 1
  209.          if pos("2 Legs",line) > 0 then tleg_no = 2
  210.       end
  211.    end
  212.    close(datafile)
  213. end
  214. else do
  215.    say
  216.    say ci_error
  217.    say
  218.    say ci_t2"'"league_file || input3_file"'."
  219.    exit
  220. end
  221.  
  222. a      = 0
  223. mcount = 0
  224. if exists(league_file || input5_file) = 0 then do
  225.    if open(datafile,league_file || input2_file,'r') then do
  226.       do while ~eof(datafile)
  227.          line = readln(datafile)
  228.          if pos("*Round="strip(tcrondn),line) > 0 then
  229.             a = 1
  230.          if a = 1 then do
  231.             if pos(separator,line) = 0 & pos('#',line) = 0 then do
  232.                mcount = mcount + 1
  233.                matches.mcount = line
  234.             end
  235.             else do
  236.                if pos("Replay",line) > 0 then do
  237.                   mcount = mcount + 1
  238.                   matches.mcount = " "
  239.                   mcount = mcount + 1
  240.                   matches.mcount = cs_t31
  241.                   mcount = mcount + 1
  242.                   matches.mcount = ""
  243.                   do cil=1 to length(cs_t31)
  244.                      matches.mcount = matches.mcount||"-"
  245.                   end
  246.                   mcount = mcount + 1
  247.                   matches.mcount = " "
  248.                end
  249.                if pos("#1st Leg",line) > 0 then do
  250.                   mcount = mcount + 1
  251.                   matches.mcount = overlay("--"ci_t3||cum_t32,line,1,length(ci_t3||cum_t32)+2)
  252.                end
  253.                if pos("#Score After Extra Time",line) > 0 then do
  254.                   mcount = mcount + 1
  255.                   matches.mcount = overlay("--"cup_saet,line,1,length(cup_saet)+2)
  256.                end
  257.                if pos("#Penalties",line) > 0 then do
  258.                   mcount = mcount + 1
  259.                   matches.mcount = overlay("--"ci_t3||strip(fc_t8),line,1,length(ci_t3||strip(fc_t8))+2)
  260.                end
  261.             end
  262.          end
  263.       end
  264.       close(datafile)
  265.    end
  266.    else do
  267.       say
  268.       say ci_error
  269.       say
  270.       say ci_t2"'"league_file||input2_file"'"ci_t4
  271.       exit
  272.    end
  273. end
  274. else do
  275.    if open(datafile,league_file || input5_file,'r') then do
  276.       do while ~eof(datafile)
  277.          line = readln(datafile)
  278.          if pos(separator,line) = 0 & pos('#',line) = 0 then do
  279.             mcount = mcount + 1
  280.             matches.mcount = line
  281.          end
  282.          else do
  283.             if pos(not_played,line) = 0 then do
  284.                if pos("Replay",line) > 0 then do
  285.                   mcount = mcount + 1
  286.                   matches.mcount = " "
  287.                   mcount = mcount + 1
  288.                   matches.mcount = cs_t31
  289.                   mcount = mcount + 1
  290.                   matches.mcount = ""
  291.                   do cil=1 to length(cs_t31)
  292.                      matches.mcount = matches.mcount||"-"
  293.                   end
  294.                   mcount = mcount + 1
  295.                   matches.mcount = " "
  296.                end
  297.                if pos("#1st Leg",line) > 0 then do
  298.                   mcount = mcount + 1
  299.                   matches.mcount = line
  300.                   matches.mcount = overlay("--"ci_t3||cum_t32,line,1,length(ci_t3||cum_t32)+2)
  301.                end
  302.                if pos("#Score After Extra Time",line) > 0 then do
  303.                   mcount = mcount + 1
  304.                   matches.mcount = line
  305.                   matches.mcount = overlay("--"cup_saet,line,1,length(cup_saet)+2)
  306.                end
  307.                if pos("#Penalties",line) > 0 then do
  308.                   mcount = mcount + 1
  309.                   matches.mcount = line
  310.                   matches.mcount = overlay("--"ci_t3||strip(fc_t8),line,1,length(ci_t3||strip(fc_t8))+2)
  311.                end
  312.             end
  313.          end
  314.       end
  315.       close(datafile)
  316.    end
  317.    else do
  318.       say
  319.       say ci_error
  320.       say
  321.       say ci_t2"'"league_file||input5_file"'"ci_t4
  322.       exit
  323.    end
  324. end
  325.  
  326. do i=1 to tcount
  327.    bpstats.i = 0
  328.    bgsstats.i = 0
  329.    bgastats.i = 0
  330.    bagstats.i = 0
  331. end
  332. np    = 0
  333. btcnt = 0
  334. if open(datafile,league_file || input2_file,'r') then do
  335.    do while ~eof(datafile)
  336.       line = readln(datafile)
  337.       btcnt = btcnt + 1
  338.       btemp.btcnt = line
  339.    end
  340.    close(datafile)
  341. end
  342. else do
  343.    say
  344.    say ci_error
  345.    say
  346.    say ci_t2"'"league_file||input2_file"'"ci_t4
  347.    exit
  348. end
  349. do k=1 to btcnt
  350.    if pos(not_played,btemp.k) = 0 & pos(separator,btemp.k) = 0 & pos('#',btemp.k) = 0 then do
  351.       teama = strip(substr(btemp.k,1,30))
  352.       teamb = strip(substr(btemp.k,41,30))
  353.       np = 1
  354.       do l=1 to tcount
  355.          if pos(teama,teams.l) > 0 then do
  356.             bpstats.l = bpstats.l + 1
  357.             l11 = k + 1
  358.             if pos("#1st Leg",btemp.l11) > 0 then
  359.                l11 = k + 2
  360.             if pos("Extra Time",btemp.l11) = 0 then do
  361.                bgsstats.l = bgsstats.l + strip(substr(btemp.k,32,2))
  362.                bgastats.l = bgastats.l + strip(substr(btemp.k,37,2))
  363.             end
  364.             else do
  365.                bgsstats.l = bgsstats.l + strip(substr(btemp.l11,32,2))
  366.                bgastats.l = bgastats.l + strip(substr(btemp.l11,37,2))
  367.             end
  368.          end
  369.          if pos(teamb,teams.l) > 0 then do
  370.             bpstats.l = bpstats.l + 1
  371.             l11 = k + 1
  372.             if pos("#1st Leg",btemp.l11) > 0 then
  373.                l11 = k + 2
  374.             if pos("Extra Time",btemp.l11) = 0 then do
  375.                bagstats.l = bagstats.l + strip(substr(btemp.k,37,2))
  376.                bgastats.l = bgastats.l + strip(substr(btemp.k,32,2))
  377.             end
  378.             else do
  379.                bagstats.l = bagstats.l + strip(substr(btemp.l11,37,2))
  380.                bgastats.l = bgastats.l + strip(substr(btemp.l11,32,2))
  381.             end
  382.          end
  383.       end
  384.    end
  385. end
  386.  
  387. if open(datafile,output_file,'w') then do
  388.    do i=1 to tcount
  389.       if bpstats.i = "" | bgsstats.i = "" | bgastats.i = "" | bagstats.i = "" then iterate
  390.       if bgastats.i = 0 then
  391. /*         average = "0.000" */
  392.          average = trunc((bgsstats.i + (bagstats.i * 1.5))*bpstats.i,3)
  393.       else
  394.          average = trunc(((bgsstats.i + (bagstats.i * 1.5))/bgastats.i)*bpstats.i,3)
  395.       bstats.i = right(average,7)"   "left(teams.i,30,' ')"    "left(bpstats.i,3,' ')"       "left(bgsstats.i+bagstats.i,3,' ')"          "left(bgastats.i,3,' ')
  396.       writeln(datafile,bstats.i)
  397.    end
  398.    close(datafile)
  399.    address command 'Exec/Sort7Chars'
  400.    btcnt = 0
  401.    if open(datafile,output_file,'r') then do
  402.       do while ~eof(datafile)
  403.          line = readln(datafile)
  404.          if line ~= "" then do
  405.             btcnt = btcnt + 1
  406.             bstats.btcnt = substr(line,9)"   "substr(line,1,8)
  407.          end
  408.       end
  409.       close(datafile)
  410.       address command 'c:delete >NIL: 'output_file
  411.    end
  412.    else do
  413.       say
  414.       say ci_error
  415.       say
  416.       say ci_t2"'"output_file"'"ci_t4
  417.       exit
  418.    end
  419. end
  420. else do
  421.    say
  422.    say ci_error
  423.    say
  424.    say ci_t2"'"output_file"'"ci_t5
  425.    exit
  426. end
  427.  
  428. if pos("YES",cuph) > 0 then
  429.    cuph = left(ci_t8,3," ")
  430. else
  431.    cuph = left(ci_t9,3," ")
  432. if pos("YES",third) > 0 then
  433.    third = left(ci_t8,3," ")
  434. else
  435.    third = left(ci_t9,3," ")
  436. if pos("YES",awaygoals) > 0 then
  437.    awaygoals = left(ci_t8,3," ")
  438. else
  439.    awaygoals = left(ci_t9,3," ")
  440.  
  441. say
  442. say center(ci_t10"'"cupname"'",78)
  443. say "-------------------------------------------------------------------------------"
  444. say
  445. say ci_t11" "awaygoals"   "ci_t12
  446. say ci_t13" "cuph
  447. if pos("MANUAL",scht) > 0 then
  448.    say ci_t14" "ci_t15
  449. else
  450.    say ci_t14" "ci_t16
  451. say ci_t17" "third
  452. say
  453. say ci_t18" "rndcnt" "ci_t19
  454. say ci_t20
  455. say
  456. say ci_t21
  457. ci_line = ""
  458. do ci_l=1 to length(ci_t21)+5
  459.    ci_line = ci_line||"-"
  460. end
  461. say ci_line
  462. say
  463. do i=1 to rndcnt
  464.    rndmsg = ""
  465.    if pos("1st",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t39)" "cs_t28,23)
  466.    if pos("2nd",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t40)" "cs_t28,23)
  467.    if pos("3rd",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t41)" "cs_t28,23)
  468.    if pos("4th",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t42)" "cs_t28,23)
  469.    if pos("5th",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t43)" "cs_t28,23)
  470.  
  471.    if pos("Quart",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t35),23)
  472.    if pos("Semi",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t33),23)
  473.    if pos("Third",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t36),23)
  474.    if pos("Final",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t30),23)
  475.  
  476.    if pos("No Ext.Time",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t3),19)
  477.    if pos("E.T If Rep.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t4),19)
  478.    if pos("Extra Time",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t5),19)
  479.  
  480.    if pos("No Pens.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t6),21)
  481.    if pos("Pen If Rep.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t7),21)
  482.    if pos("Penalties",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t8),21)
  483.  
  484.    if pos("2 Legs",rnds.i) > 0 then rndmsg = rndmsg||fc_t2
  485.    say rndmsg
  486. end
  487. say
  488. say "_______________________________________________________________________________"
  489. say
  490. say
  491. say ci_t22
  492. ci_line = ""
  493. do ci_l=1 to length(ci_t22)
  494.    ci_line = ci_line||"-"
  495. end
  496. say ci_line
  497. say
  498. say ci_t23
  499. say
  500. say ci_t24
  501. ci_line = ""
  502. do ci_l=1 to length(ci_t24)
  503.    ci_line = ci_line||"-"
  504. end
  505. say ci_line
  506. do i=1 to tcount
  507.    say left(i,3,' ')" "bstats.i
  508. end
  509. say
  510. say
  511. say ci_t25"  "tcount
  512.  
  513. ci_line = ""
  514. do ci_l=1 to length(ci_t25)
  515.    ci_line = ci_line||"-"
  516. end
  517. say ci_line
  518. say
  519. do i=1 to tcount by 2
  520.    a = i + 1
  521.    say left(teams.i,30,' ')"    "teams.a
  522. end
  523. say
  524. say "_______________________________________________________________________________"
  525. say
  526. if tleg_no = 0 then legged = "Blank"
  527. if tleg_no = 1 then legged = "1 Leg"
  528. if tleg_no = 2 then legged = "2 Legs"
  529. tempname = ci_t26" : "bettername(word(rnds.crond,1),legged)
  530. say tempname
  531. uline = ''
  532. do i=1 to length(tempname)
  533.    uline = uline||"-"
  534. end
  535. say uline
  536. say
  537. do i=1 to mcount
  538.    if matches.i ~= "" then
  539.       say matches.i
  540. end
  541. say
  542. if pos("Yes",cuph) > 0 & exists(league_file||input4_file) > 0 then do
  543.    say "_______________________________________________________________________________"
  544.    say
  545.    say ci_t27
  546.    ci_line = ""
  547.    do ci_l=1 to length(ci_t27)
  548.       ci_line = ci_line||"-"
  549.    end
  550.    say ci_line
  551.    say
  552.    if open(datafile,league_file || input4_file,'r') then do
  553.       do while ~eof(datafile)
  554.          line = readln(datafile)
  555.          if pos(first,line)   > 0 then do
  556.             parse var line "*WINNER="wteam
  557.             say wteam
  558.          end
  559.       end
  560.       close(datafile)
  561.    end
  562.    else do
  563.       say
  564.       say ci_error
  565.       say
  566.       say ci_t2"'"league_file || input4_file"'"
  567.       exit
  568.    end
  569.    say
  570. end
  571. say "-------------------------------------------------------------------------------"
  572. say
  573.  
  574. exit
  575.  
  576. /* Routine ----------------------------------------------------------- */
  577.  
  578. bettername:
  579. parse arg crn,legless
  580.  
  581. trdn = strip(substr(crn,1,1))
  582. if datatype(trdn,'n') = 1 then do
  583.    parse var crn roundno" "extra
  584.    trn = strip(crn)" "cs_t28" "extra
  585. end
  586. else do
  587.    if pos(cs_t30,crn) > 0 then do
  588.       parse var crn . " "extra
  589.       if pos(cs_t31,crn) > 0 then
  590.          trn = cs_t30" "extra
  591.       else
  592.          trn = cs_t30
  593.    end
  594.    if pos(strip(cs_t45),crn) > 0 then do
  595.       parse var crn . " "extra
  596.       if pos(cs_t31,crn) > 0 then
  597.          trn = cs_t32" "extra
  598.       else
  599.          trn = cs_t33
  600.    end
  601.    if pos(strip(cs_t44),crn) > 0 then do
  602.       parse var crn . " "extra
  603.       if pos(cs_t31,crn) > 0 then
  604.          trn = cs_t34" "extra
  605.       else
  606.          trn = cs_t35
  607.    end
  608.    if pos(strip(cs_t46),crn) > 0 then do
  609.       trn = cs_t36
  610.    end
  611. end
  612.  
  613. if pos("1 Leg",legless) > 0 then
  614.    trn = trn||"  ("cum_t32")"
  615. if pos("2 Legs",legless) > 0 then
  616.    trn = trn||"  ("cum_t33")"
  617.  
  618. return trn
  619.  
  620. /* ------------------------------------------------------------------- */